package com.demo.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.demo.bean.Paper;
import com.demo.exception.FileUploadException;

@Controller
@SessionAttributes(names= {"name","now"})
public class IndexController {

	@Resource
	Paper paper9;
	
	@Resource
	Paper paper10;
	
	@GetMapping("/")
	public String index(Model model, HttpServletRequest req) throws FileUploadException {
		req.getRemoteAddr();
		model.addAttribute("name", "今天礼拜五");
		model.addAttribute("now", new Date());
		List<String> set = new ArrayList<String>();
		set.add("西瓜");set.add("苹果");
		model.addAttribute("age", 16);
		model.addAttribute("list", set);
		
		
		System.out.println("这是一个从@Configuration+@Bean注解拿过来的对象"+paper9+paper10);
		
		return "index";
	}
	
	@GetMapping("/index/b")
	public String b(Model model) {
		model.addAttribute("name", "明天是新年");
		
		
		return "b";
	}
}
